package com.sgb.capital.view.ui.adapter;

import android.content.Context;
import android.text.SpannableString;
import android.widget.TextView;

import com.sgb.capital.BR;
import com.sgb.capital.R;
import com.sgb.capital.base.BaseRecycleAdapter;
import com.sgb.capital.model.ReimburseBean;
import com.sgb.capital.utils.ItemViewHolder;
import com.sgb.capital.utils.Utils;

import java.util.List;

/**
 * 作者:张磊
 * 日期:2021/12/15 0015
 * 说明:退款列表的item
 */
public class ReimburseAdapter extends BaseRecycleAdapter<ReimburseBean.ListDTO> {

    public ReimburseAdapter(Context context, List<ReimburseBean.ListDTO> beans) {
        super(context, R.layout.reimburse_adapter, beans);
    }

    @Override
    public void convert(ItemViewHolder holder, ReimburseBean.ListDTO item) {
        holder.setBinding(BR.viewModel, item);
        SpannableString orderId = Utils.getKeyWordSpan(Utils.getColor(R.color.color_333333), "退费单号：" + item.orderId, item.orderId);
        SpannableString created = Utils.getKeyWordSpan(Utils.getColor(R.color.color_333333), "申请时间：" + Utils.getTime(item.created), Utils.getTime(item.created));
        SpannableString refundAmount = Utils.getKeyWordSpan(Utils.getColor(R.color.color_FF4B10), "退款金额：" + ("￥" + Utils.getDecimalFormat(item.refundAmount)), ("￥" + Utils.getDecimalFormat(item.refundAmount)));
        //  0.待处理,1.退款中,2退费成功,3退费失败 6.已拒绝)   {"全部", "待处理", "已拒绝", "退款中", "已完成", "已失败"};
        holder
                .setText(R.id.tv_tradeType, item.tradeType)
                .setText(R.id.tv_status, item.status == 0 ? "待处理" :
                        item.status == 1  || item.status==4 || item.status==5 ? "退款中" :
                                item.status == 2 ? "已完成" :
                                item.status == 3 ? "已失败" :
                                        "已拒绝")
                .setText(R.id.tv_orderId, orderId)
                .setText(R.id.tv_refundAmount, refundAmount)
                .setText(R.id.tv_created, created)
                .setText(R.id.tv_applyName, item.applyName);

        TextView tv_status = holder.getView(R.id.tv_status);
        tv_status.setTextColor(Utils.getColor(
                item.status == 0 ? R.color.color_FFC000 :
                        (item.status == 1 || item.status == 4 || item.status == 5) ? R.color.color_5792FD :
                                item.status == 2 ? R.color.color_06C764 :
                                item.status == 3 ? R.color.color_FF4B10 :
                                        R.color.color_969696));

    }

}


